<style scoped>
.between text{
	display: flex;
	flex: 1;
	font-size: 28upx;
}
.online-money{
	padding-left: 8upx;
}
.time{
	font-size: 20upx;
}
</style>
<template>
	<view class="flexview">
		<view class="uni-list">
			<view class="uni-list-cell" v-for="(item,index) in list" :key="index">
				<view class="uni-list-cell-navigate between">
					<text>{{item.gname}}</text>
					<text class="online-money">{{item.usemoney}}充值金</text>
					<text>{{item.status}}</text>
					<text class="time">{{item.createtm}}</text>
				</view>
			</view>
			<view v-if="list.length==0" class="nodata">
				<image src="../../static/img/nodata.png" mode=""></image>
			</view>
			<div class="nomore" v-if="!hasMore&&list.length>0">没有更多了</div>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[
// 					{
// 						time:'2018-12-14 10:05:20',
// 						price:'30'
// 					}
				],
				hasMore:true,
				pageNum:1,
				pageSize:20,
			};
		},
		methods:{
			getList(){
				let that = this
				uni.request({
					url: this.httpUrl + 'userOrder/list4Page',
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						uid:that.$store.state.userInfo.uid,
						pageNum: that.pageNum,
						pageSize: that.pageSize
					},
					success: (res) => {
						console.log(res)
						if (res.data.code == 1) {
							that.list.push(...res.data.data.data)
							that.list.forEach(item=>{
								switch (item.status){
									case 1:
									    item.status = '已支付'
									case 2:
									    item.status = '已领取'	
										break;
									default:
										break;
								}
							})
// 							let data = res.data.data.data
// 							for(let i=0;i<data.length;i++){
// 								that.list.push(data[i].children[0])
// 							}
							console.log(that.list);
							if(res.data.data.data.length < that.pageSize){
								that.hasMore = false
							}else{
								that.hasMore = true
								that.pageNum ++
							}
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: 'none',
								mask: true
							})
						}
					}
				})
			}
		},
		onReachBottom(){
		  if(this.hasMore){
			  this.getList()
		  }
		},
		onLoad() {
			this.getList()
		}
	}
</script>
